package org.ens.delegation.bo;

import java.io.Serializable;

import javax.persistence.Embeddable;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;

/**
 * @author amine
 *
 */
@Embeddable
public class AgentGradePK implements Serializable{

	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	
	private Agent agent;
	private Grade grade;
	
	@ManyToOne
	@JoinColumn(name="code_agen")
	public Agent getAgent() {
		return agent;
	}
	
	public void setAgent(Agent agent) {
		this.agent = agent;
	}
	
	@ManyToOne
	@JoinColumn(name="code_grade")
	public Grade getGrade() {
		return grade;
	}
	
	public void setGrade(Grade grade) {
		this.grade = grade;
	}
	
	@Override
	public boolean equals(Object obj) {
		if(obj == null || !(obj instanceof AgentGradePK))
			return false;
		
			AgentGradePK agentGradePK = (AgentGradePK) obj;
			if(agentGradePK.getAgent() == null || agentGradePK.getGrade() == null)
				return false;
			
			return (agentGradePK.getAgent().equals(this.getAgent()) && agentGradePK.getGrade().equals(this.getGrade()));
	}

}
